package com.ghost.UI
{
	import com.adobe.cairngorm.control.CairngormEventDispatcher;
	import com.ghost.event.Skin_Event;
	
	import fl.controls.UIScrollBar;
	
	import flash.events.Event;
	import flash.media.SoundTransform;

	/**
	 * @author ghost
	 * 滚动条
	 */
	public class Ghost_scroll extends UIScrollBar
	{
		private var style_v:Vector.<Object>;//样式数组
		private var style_str_v:Vector.<String>;//样式名数组
		private var style_length:int = 17;//样式名个数
		/**
		 * @param skin_v 皮肤数据(包含向上 向下箭头 轨道和滚动条 16个数据)
		 * @param soundtransform 声音
		 */		
		public function Ghost_scroll(skin_v:Vector.<Object>=null)
		{
			this.addEventListener(Event.REMOVED_FROM_STAGE,remove_Handler);
			if(skin_v != null)
			{
				style_v = new Vector.<Object>();
				style_v = skin_v;
				style_str_v = new <String>['upArrowDisabledSkin','upArrowDownSkin','upArrowOverSkin','upArrowUpSkin',
					'downArrowDisabledSkin','downArrowDownSkin','downArrowOverSkin','downArrowUpSkin',
					'trackDisabledSkin','trackDownSkin','trackOverSkin','trackUpSkin',
					'thumbDisabledSkin','thumbDownSkin','thumbOverSkin','thumbUpSkin','thumbIcon'];
				register_style(style_v);
			}
			CairngormEventDispatcher.getInstance().addEventListener(Skin_Event.skin_change_event,change_Handler);//所有不同ui更换
		}
		/**
		 * 设置样式
		 * @param v:样式数组
		 */		
		private function register_style(v:Vector.<Object>):void
		{
			var i:int = 0;
			for(i;i<style_length;i++)
			{
				this.setStyle(style_str_v[i],style_v[i]);
			}
		}
		private function remove_Handler(e:Event):void
		{
			this.removeEventListener(Event.REMOVED_FROM_STAGE,remove_Handler);
			CairngormEventDispatcher.getInstance().removeEventListener(Skin_Event.skin_change_event,change_Handler);//所有不同ui更换
		}
		/**
		 * 按钮更换样式 e.data可以是数字 代表第几套皮肤
		 */		
		private function change_Handler(e:Skin_Event):void
		{
			register_style(e.data);
		}
	}
}